package com.vallis.statis;

import cn.hutool.core.math.MathUtil;

import java.util.*;

/**
 * @Classname TestCalc
 * @Description TODO
 * @Date 2020/12/2 17:25
 * @Created by vallis
 */
public class TestCalc {
   
   
    void get1(){
        List<String[]> strings = MathUtil.combinationSelect(new String[]{"1", "2", "4", "5", "6"}, 2);
        List<String[]> strings1 = MathUtil.combinationSelect(new String[]{"7", "2", "4", "5", "6"}, 2);
    
    
        List<String[]> x=new ArrayList<>();
        x.addAll(strings);
        x.addAll(strings1);
        System.out.println("母list共有"+x.size()+"个元素");
        List<String[]> xc=new ArrayList<>();
        Iterator<String[]> iter = x.iterator();
    
        while (iter.hasNext()){
            String[] t=iter.next();
            if(contains(x,t)){
                System.out.println("母list剩余"+x.size()+"个元素");
                iter.remove();
            }else{
                xc.add(t);
            }
        
            System.out.println(xc.size());
        
        }
        
    }
    public static boolean contains(List<String[]> a, String[] b){
        if (a.size()==1){
            return false;
        }
        for (String[] strings : a) {
            if (Arrays.equals(strings,b)){
                return true;
            }
        }
        return false;
    }
    public  static    List<String[]> analysisArrayList(List<String[]> arrayList) {
        Set<String[]> set = new TreeSet<String[]>(new Comparator<String[]>() {
            @Override
            public int compare(String[] o1, String[] o2) {
                return o1[1].compareTo(o2[1]);//第二个元素去重
            }
        });
        set.addAll(arrayList);
        List<String[]> list = new ArrayList<>(set);
        return list;
    }
}
